package com.swind.fast.modules.app.halali.partner.service.impl;

import com.swind.fast.common.util.oConvertUtils;

import com.swind.fast.modules.app.halali.partner.entity.RestaurantDealCategory;
// import com.swind.fast.modules.app.halali.partner.entity.RestaurantDealCategoryBill;
import com.swind.fast.modules.app.halali.partner.mapper.RestaurantDealCategoryMapper;
import com.swind.fast.modules.app.halali.partner.service.IRestaurantDealCategoryService;
// import com.swind.fast.modules.app.halali.partner.model.SpaceAnnouncementModel;

import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.context.ApplicationContext;

import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import cn.hutool.core.date.DateBetween;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateTime;

import javax.annotation.Resource;

import java.util.stream.Collectors;

import lombok.extern.slf4j.Slf4j;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import com.swind.fast.modules.app.halali.partner.vo.request.DealVo;

/**
 * @Description: 项目
 * @Author: swind
 * @Date:   2021-11-20
 * @Version: V1.0
 */
@Slf4j
@Service
public class RestaurantDealCategoryServiceImpl extends ServiceImpl<RestaurantDealCategoryMapper, RestaurantDealCategory> implements IRestaurantDealCategoryService {

    public void saveCategories(String dealId, DealVo dealVo) {
        List<String> ids = dealVo.getCategoryIds();
        List<RestaurantDealCategory> saveItems = new ArrayList<RestaurantDealCategory>();
        for (String id : ids) {
            RestaurantDealCategory cat = new RestaurantDealCategory();
            cat.setDealId(dealId);
            cat.setRestaurantCategoryId(id);
            saveItems.add(cat);
        }
        this.baseMapper.removeItems(dealId);
        this.saveBatch(saveItems);
    }
}
